package dk.rhok.findstufffast;



import android.view.*;
import android.content.*;
import android.util.AttributeSet;
import android.graphics.*;



public class Arrow extends View
{
    private Bitmap bitmap;
    private Matrix matrix;
    private float direction;
 


    public Arrow(Context context, AttributeSet attributes)
    {
        super(context, attributes);
        init(context);
    }



    public Arrow(Context context)
    {
        super(context);
        init(context);
    }



    private void init(Context context)
    {
        bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.arrow1);
        matrix = new Matrix();
    }



    public void setDirection(float direction)
    {
        this.direction = direction;
    }



    @Override
    public void onDraw(Canvas canvas)
    {
        matrix.reset();
        matrix.postTranslate(-bitmap.getWidth()/2f, -bitmap.getHeight()/2f);
        matrix.postRotate(direction);
        matrix.postTranslate(getWidth()/2f, getHeight()/2f);
        canvas.drawBitmap(bitmap, matrix, null);
    }
}